package com.example.jwttest.Md5Test;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;
import java.util.UUID;

public class Md5Test {
    public static String encrypt(String password) {
        String salt= UUID.randomUUID().toString().replace("-","");
        String s2= DigestUtils.md5DigestAsHex((salt+password).getBytes(StandardCharsets.UTF_8));
        return salt+s2;
    }
public static String check(String password,String scret){
        String salt=scret.substring(0,32);
        String s2= DigestUtils.md5DigestAsHex((salt+password).getBytes(StandardCharsets.UTF_8));
        return salt+s2;
}
    public static void main(String[] args) {
        String s1=Md5Test.encrypt("123453");
        System.out.println(s1);
        String s2=Md5Test.check("123456",s1);
        System.out.println(s2);
    }
}
